# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Henrik Riomar <henrik.riomar@gmail.com>
pkgname=libb64
pkgver=2.0.0.1
pkgrel=0
pkgdesc="Fast Base64 encoding/decoding routines"
url="https://github.com/libb64/libb64"
arch="all"
license="Public-Domain"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/libb64/libb64/archive/v$pkgver/libb64-$pkgver.tar.gz
	0001-Fix-off-by-one-bug-reported-by-Gabriel-Kihlman-4.patch
	0002-Include-stddef.h-to-import-size_t-definition.patch
	0001-Makefile-fix-parallel-build-of-examples.patch
	0001-examples-Use-proper-function-prototype-for-main.patch
	0002-use-BUFSIZ-as-buffer-size.patch
	"

build() {
	make all_base64
	${CC:-cc} $LDFLAGS $CFLAGS -shared -Wl,-soname,${pkgname}.so.0 src/*.o -o src/${pkgname}.so.0
}

check() {
	make -C examples test
}

package() {
	install -Dm 0644 src/libb64.a -t "$pkgdir"/usr/lib
	install -Dm 0644 src/libb64.so.0 -t "$pkgdir"/usr/lib
	ln -s libb64.so.0 "$pkgdir"/usr/lib/libb64.so

	install -Dm 0644 include/b64/*.h -t "$pkgdir"/usr/include/b64/
	install -Dm 0644 ./*.md -t "$pkgdir"/usr/share/doc/"$pkgname"/

}

sha512sums="
72c2fd4c81575b505f4851cd3820b6a2d8e78cd031a1ed138ffe5667ca711558f43b515428971966f7a73ace7c9951f1f0b39c362a59fe4691958875775cce23  libb64-2.0.0.1.tar.gz
00828c18042397ea491a1f0a7ecd6dfcb4383d8ef95ba7a808e6e0f8938a2f59eeb1f1bb25ed60633890795c76a8201c27ae89a1d8751581570bf94de54e4218  0001-Fix-off-by-one-bug-reported-by-Gabriel-Kihlman-4.patch
825bb603353615ecd3bfcccc30f3837331b6e84a05acb862f2ca6137c94326c669b74d3886ee48bbe121e1b86ed7719875934744499fcd479d8482d279111198  0002-Include-stddef.h-to-import-size_t-definition.patch
423b6b9a4a03d959f2d9b38e0a498a696eced57aa66c831e696a36f52530e4e74246f351c449839e7898441969e823305c9c431af7988e01d746e75e38e2e7bf  0001-Makefile-fix-parallel-build-of-examples.patch
099eaa8bdd2644ef05ba08f605f1e76116cc2c62ddbdc6bd495305dac97b06d7449b87d243e1e23aa73a252ddde0fcfd2edc77c6ece89ff7c8c972f0936a758d  0001-examples-Use-proper-function-prototype-for-main.patch
c90e3aaa5998bea12cfc80b97ea5a072be8c677659d77a0e0a8702db973a1426dbec2ddb2701abeb87ad75fe0aa7ba2caca8f1f519e84746ad56f6caec257abf  0002-use-BUFSIZ-as-buffer-size.patch
"
